package com.performax.service;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.google.android.gcm.server.Message;
import com.google.android.gcm.server.Result;
import com.google.android.gcm.server.Sender;
import com.performax.database.Vo.*;
import com.performax.database.Dao.*;
import com.performax.utils.Oh2gameUtils;


@Controller
@RequestMapping("/app/api/mypage")
public class OheGameMyController {
	
	private static final Logger logger = LoggerFactory.getLogger(OheGameMyController.class);
	
	@Resource(name = "oh2gameMypageDao")
	private Oh2GameMypageDao oh2gameMypageDao;
	
	@Resource(name = "oh2gameGlobalDao")
	private	Oh2GameGlobalDao oh2gameGlobalDao;
	
	@RequestMapping(value="/profileimgreg")
	@ResponseBody
	public Object profileimgreg(@RequestParam(value="authKey", required=true) 				String authKey
								,@RequestParam(value="mediaCd", defaultValue="mcdoheapp")	String mediaCd
								,@RequestParam(value="userId", required=true) 				String userId
								,@RequestParam(value="gid", defaultValue="XXXXXXXXXX") 		String gid
								,HttpServletRequest req ) throws Exception
	{
		HashMap<String, Object> param	=	new	HashMap<String, Object>();
		
		String	serverBasePath	=	oh2gameGlobalDao.getFileSavePath("FILE_SAVE_BASE_PATH");
		String uploadPath	=	new StringBuffer().append(oh2gameGlobalDao.getFileSavePath("USER_PROFILE_PATH")).toString();
		
		String bucketName	=	"oh2game";	
		String serviceDomain	=	oh2gameGlobalDao.getFileSavePath("AWS_IMAGE_SERVER_DOMAIN");
		
		File upPath	=	new	File(serverBasePath+uploadPath);
			
		if(!upPath.exists()){
			upPath.mkdir();
		}
			
		MultipartHttpServletRequest multipart	=	(MultipartHttpServletRequest)req;
		MultipartFile	file	=	multipart.getFile("upFile");
		File	f	=	new	File(file.getOriginalFilename());
		file.transferTo(f);
		
		try{
			
			String orgName	=	URLDecoder.decode(new String(file.getOriginalFilename().getBytes()), "UTF-8");
			String	extName	=	orgName.substring(orgName.lastIndexOf("."), orgName.length());
			orgName	=	new StringBuffer().append(userId).append("_profile_").append(System.currentTimeMillis()).append(extName).toString();
			String serverName	=	new StringBuffer().append(orgName).toString();
			
			String url	=	Oh2gameUtils.transferS3SingleFile(f, uploadPath, bucketName, serviceDomain, serverName);
			
			
			//FileCopyUtils.copy(file.getInputStream(), new FileOutputStream(serverBasePath+uploadPath+serverName));
					
			//String url		=	"http://"+oh2gameGlobalDao.getFileSavePath("SERVICE_DOMAIN")+"/"+oh2gameGlobalDao.getFileSavePath("USER_PROFILE_PATH")+serverName;
			
			param.put("userId"	, userId);
			param.put("url"		, url);
			param.put("path"	, serverBasePath+uploadPath+orgName);
		
		}catch(Exception e){
			e.printStackTrace();
		}
		
		oh2gameMypageDao.updateProfile(param);
		
		param.put("authKey", 	authKey);
		param.put("mediaCd", 	mediaCd);
		param.put("userId", 	userId);
		param.put("gid", 		gid);
		
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType","profileimgreg");
		result.put("result","1000");
		result.put("fileUrl",param.get("url"));
		result.put("resultMessage", param);
		return result;
	}
	
	@RequestMapping(value="/getprofile")
	@ResponseBody
	public Object getProfile(@RequestParam(value="authKey", required=true) 				String authKey
								,@RequestParam(value="mediaCd", defaultValue="mcdoheapp")	String mediaCd
								,@RequestParam(value="userId", required=true) 				String userId
								,@RequestParam(value="gid", defaultValue="XXXXXXXXXX") 		String gid
								,HttpServletRequest req )
	{
		String url	=	oh2gameMypageDao.getProfile(userId);
		
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType","getprofile");
		result.put("result","1000");
		result.put("profileUrl",url);
		
		Hashtable<String, String> param	=	new	Hashtable<String, String>();
		
		param.put("authKey", authKey);
		param.put("mediaCd", mediaCd);
		param.put("userId", userId);
		param.put("gid", 	gid);
		
		
		result.put("resultMessage", param);
		return result;
	}
	
	@RequestMapping(value="/profileimgdel")
	@ResponseBody
	public Object profileimgdel(@RequestParam(value="authKey", required=true) 				String authKey
								,@RequestParam(value="mediaCd", defaultValue="mcdoheapp")	String mediaCd
								,@RequestParam(value="userId", required=true) 				String userId
								,@RequestParam(value="gid", defaultValue="XXXXXXXXXX") 		String gid
								,HttpServletRequest req )
	{
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType","profileimgdel");
		result.put("result","1000");
		
		oh2gameMypageDao.removeProfile(userId);
		
		Hashtable<String, String> param	=	new	Hashtable<String, String>();
		
		param.put("authKey", authKey);
		param.put("mediaCd", mediaCd);
		param.put("userId", userId);
		param.put("gid", 	gid);
		
		
		result.put("resultMessage", param);
		return result;
	}
	
	@RequestMapping(value="/reginfolist")
	@ResponseBody
	public Object reginfolist(@RequestParam(value="authKey", 		required=true) 					String authKey
								,@RequestParam(value="mediaCd", 	defaultValue="mcdoheapp")		String mediaCd
								,@RequestParam(value="userId", 		required=true) 					String userId
								,@RequestParam(value="gid", 		defaultValue="XXXXXXXXXX") 		String gid
								,@RequestParam(value="reqPage", 	defaultValue="1") 				int reqPage
								,@RequestParam(value="listPerPage", defaultValue="30") 				int listPerPage
								,HttpServletRequest req )
	{
		int start = (reqPage * listPerPage - listPerPage);
		
		HashMap<String, Object> param	=	new	HashMap<String, Object>();
		
		param.put("authKey", 		authKey);
		param.put("mediaCd", 		mediaCd);
		param.put("userId", 		userId);
		param.put("gid", 			gid);
		param.put("listPerPage", 	listPerPage);
		param.put("start", 			start);
		
		List<EventInfoVo> eventList	=	oh2gameMypageDao.getRegEventList(param);
		int				  listCnt	=	oh2gameMypageDao.getRegEventCount(userId);
		
		String lastPage	=	"Y";
		
		if(listCnt > (reqPage*listPerPage)){
			lastPage	=	"N";
		}
		
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType","reginfolist");
		result.put("result","1000");
		result.put("listCnt",	eventList.size());
		result.put("pageNo",	reqPage);
		result.put("lastPage",	lastPage);
	
		result.put("eventInfo",eventList);
		
		result.put("resultMessage", param);
		return result;
		
	}
	
	/*@RequestMapping(value="/reginfodel")
	@ResponseBody
	public Object reginfodel(@RequestParam(value="authKey", required=true) 				String authKey
							,@RequestParam(value="mediaCd", defaultValue="mcdoheapp")	String mediaCd
							,@RequestParam(value="userId", required=true) 				String userId
							,@RequestParam(value="gid", defaultValue="XXXXXXXXXX") 		String gid
							,@RequestParam(value="eventId", required=true) 				String eventId
							,HttpServletRequest req )
	{
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType","reginfodel");
		result.put("result","1000");
		
		Hashtable<String, String> param	=	new	Hashtable<String, String>();
		
		param.put("authKey", 	authKey);
		param.put("mediaCd", 	mediaCd);
		param.put("userId", 	userId);
		param.put("gid", 		gid);
		param.put("eventId", 	eventId);
		
		result.put("resultMessage", param);
		return result;
	}*/
	
	@RequestMapping(value="/myboardlist")
	@ResponseBody
	public Object myboardlist(@RequestParam(value="authKey", 		required=true) 				String authKey
								,@RequestParam(value="mediaCd", 	defaultValue="mcdoheapp")	String mediaCd
								,@RequestParam(value="userId", 		required=true) 				String userId
								,@RequestParam(value="gid", 		defaultValue="XXXXXXXXXX") 	String gid
								,@RequestParam(value="reqPage", 	defaultValue="1") 			int reqPage
								,@RequestParam(value="listPerPage", defaultValue="30") 			int listPerPage
								,@RequestParam(value="category", 	required=true) 				String category
								,HttpServletRequest req )
	{	
		HashMap<String, Object> param	=	new	HashMap<String, Object>();
		
		param.put("authKey", 	authKey);
		param.put("mediaCd", 	mediaCd);
		param.put("userId", 	userId);
		param.put("gid", 		gid);
		param.put("reqPage",	reqPage);
		param.put("listPerPage",listPerPage);
		param.put("category",	category);
		
		int				  listCnt	=	0;
		String lastPage	=	"Y";
		int start = (reqPage * listPerPage - listPerPage);
		
		
		if(category.equals("B")){
			listCnt	=	oh2gameMypageDao.getMyBoardListCnt(userId);
		}else if(category.equals("ER")){
			listCnt	=	oh2gameMypageDao.getMyEventReplyListCnt(userId);
		}else if(category.equals("BR")){
			listCnt	=	oh2gameMypageDao.getMyBoardReplyListCnt(userId);
		}
		
		if(listCnt > (reqPage*listPerPage)){
			lastPage	=	"N";
		}
		
		param.put("start", start);
		
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		if(category.equals("B")){
			List<BoardInfoVo>	boardInfo	=	oh2gameMypageDao.getMyBoardList(param);
			result.put("boardInfo", boardInfo);
			result.put("listCnt",boardInfo.size());
		}else if(category.equals("ER")){
			List<ReplyInfoVo>	replyInfo	=	oh2gameMypageDao.getMyEventReplyList(param);
			result.put("replyInfo", replyInfo);
			result.put("listCnt",replyInfo.size());
		}else if(category.equals("BR")){
			List<BoardReplyInfoVo> boardReplyInfo	=	oh2gameMypageDao.getMyBoardReplyList(param);
			result.put("boardReplyInfo", boardReplyInfo);
			result.put("listCnt",boardReplyInfo.size());
		}
		
		result.put("resType","myboardlist");
		result.put("result","1000");
		result.put("category",category);
		result.put("pageNo",reqPage);
		result.put("lastPage",lastPage);
		
		result.put("resultMessage", param);
		return result;	
	}
	
	
	@RequestMapping(value="/phoneupdate")
	@ResponseBody
	public Object phoneupdate(@RequestParam(value="authKey", 	required=true) 				String authKey
								,@RequestParam(value="mediaCd", defaultValue="mcdoheapp")	String mediaCd
								,@RequestParam(value="userId", 	required=true) 				String userId
								,@RequestParam(value="gid", 	defaultValue="XXXXXXXXXX") 	String gid
								,@RequestParam(value="phoneNo", required=true) 				String phoneNo
								,@RequestParam(value="authNo", 	required=true) 				String authNo
								//,@RequestParam(value="pushKey", required=true) 				String pushKey
								,HttpServletRequest req )
	{
		
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType","phoneupdate");
		result.put("result","1000");
		
		
		
		Hashtable<String, String> param	=	new	Hashtable<String, String>();
		
		param.put("authKey", 	authKey);
		param.put("mediaCd", 	mediaCd);
		param.put("userId", 	userId);
		param.put("gid",	 	gid);
		param.put("phoneNo",	phoneNo);
		param.put("authNo",		authNo);
		
		result.put("resultMessage", param);
		return result;
	}
		
		
	
	@RequestMapping(value="/pswdupdate")
	@ResponseBody
	public Object pswdupdate(@RequestParam(value="authKey", 	required=true) 			String authKey
							,@RequestParam(value="mediaCd", defaultValue="mcdoheapp")	String mediaCd
							,@RequestParam(value="userId", 	required=true) 				String userId
							,@RequestParam(value="gid", 	defaultValue="XXXXXXXXXX") 	String gid
							,@RequestParam(value="prevPw", 	required=true) 				String prevPw
							,@RequestParam(value="toPw", 	required=true) 				String toPw
							,HttpServletRequest req )
	{
		HashMap<String, Object> param	=	new	HashMap<String, Object>();
		
		param.put("authKey", 	authKey);
		param.put("mediaCd", 	mediaCd);
		param.put("userId", 	userId);
		param.put("gid", 		gid);
		param.put("prevPw",		prevPw);
		param.put("toPw",		toPw);
		
		String msg	=	oh2gameMypageDao.updatePassword(param);
		String resultCode	=	"1000";
		
		if(!msg.equals("success")){
			resultCode	=	"9999";
		}
		
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType","pswdupdate");
		result.put("result",resultCode);
		result.put("resultMessage", msg);
		return result;
	}

	
	@RequestMapping(value="/prefupdate")
	@ResponseBody
	public Object prefupdate(@RequestParam(value="authKey", 	required=true) 			String authKey
							,@RequestParam(value="mediaCd", defaultValue="mcdoheapp")	String mediaCd
							,@RequestParam(value="userId", 	required=true) 				String userId
							,@RequestParam(value="gid", 	defaultValue="XXXXXXXXXX") 	String gid
							,@RequestParam(value="genre", 	required=true) 				String genre
							,HttpServletRequest req )
	{
		HashMap<String, Object> param	=	new	HashMap<String, Object>();
		
		param.put("authKey", 	authKey);
		param.put("mediaCd", 	mediaCd);
		param.put("userId", 	userId);
		param.put("gid", 		gid);
		param.put("genre", 		genre);
		
		oh2gameMypageDao.updateGenre(param);
		
		
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType","prefupdate");
		result.put("result","1000");
		result.put("genre",genre);
		
		result.put("resultMessage", param);
		return result;
	}
	
	@RequestMapping(value="/dropout")
	@ResponseBody
	public Object dropout(	@RequestParam(value="authKey", 	required=true) 				String authKey
							,@RequestParam(value="mediaCd", defaultValue="mcdoheapp")	String mediaCd
							,@RequestParam(value="userId", 	required=true) 				String userId
							,@RequestParam(value="gid", 	defaultValue="XXXXXXXXXX") 	String gid
							,@RequestParam(value="reason", 	required=true) 				String reason
							,@RequestParam(value="pw", 		required=true) 				String pw
							,HttpServletRequest req )
	{
		HashMap<String, Object>  param	=	new	HashMap<String, Object> ();
		
		param.put("authKey", 	authKey);
		param.put("mediaCd", 	mediaCd);
		param.put("userId", 	userId);
		param.put("gid", 		gid);
		param.put("reason", 	reason);
		param.put("prevPw", 	pw);
		
		String msg	=	oh2gameMypageDao.dropOut(param);
		String resultCode	=	"1000";
		
		if(!msg.equals("success")){
			resultCode	=	"9999";
		}
		
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType","dropout");
		result.put("result",resultCode);
		result.put("resultMessage", msg);
		return result;
	}
	
	@RequestMapping(value="/friendsetting")
	@ResponseBody
	public Object friendsetting(@RequestParam(value="authKey", 	required=true) 				String authKey
								,@RequestParam(value="mediaCd", defaultValue="mcdoheapp")	String mediaCd
								,@RequestParam(value="userId", 	required=true) 				String userId
								,@RequestParam(value="gid", 	defaultValue="XXXXXXXXXX") 	String gid
								,HttpServletRequest req )
	{
		HashMap<String, Object> param	=	new	HashMap<String, Object>();
		
		param.put("authKey", 	authKey);
		param.put("mediaCd", 	mediaCd);
		param.put("userId", 	userId);
		param.put("gid", 		gid);
		
		
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType","friendsetting");
		result.put("result","1000");
		
		String	status	=	oh2gameMypageDao.getCommFriendStatus(userId);
		result.put("commFrType",status);
		 
		List<EventFriendInfoVo> eventFrList	=	oh2gameMypageDao.getEventFriendList(userId);
		result.put("listCnt", eventFrList.size());
		result.put("eventFrType",eventFrList);
		result.put("resultMessage", param);
		return result;
	}
	
	@RequestMapping(value="/getinfo")
	@ResponseBody
	public Object getinfo(@RequestParam(value="authKey", 	defaultValue="") 			String authKey
							,@RequestParam(value="mediaCd", defaultValue="mcdoheapp")	String mediaCd
							,@RequestParam(value="userId", 	defaultValue="") 			String userId
							,@RequestParam(value="gid", 	defaultValue="XXXXXXXXXX") 	String gid
							,HttpServletRequest req )
	{
		Hashtable<String, String> param	=	new	Hashtable<String, String>();
		
		param.put("authKey", 	authKey);
		param.put("mediaCd", 	mediaCd);
		param.put("userId", 	userId);
		param.put("gid", 		gid);
		
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType","getinfo");
		result.put("result","1000");
		
		HashMap<String, Object> appInfo	=	oh2gameMypageDao.getAppInfo();
		
		result.put("thumbNailUrl",	(String)appInfo.get("thumbNailUrl"));
		result.put("curVer",		(String)appInfo.get("curVer"));
		result.put("marketUrl",		(String)appInfo.get("marketUrl"));
		result.put("conditionUrl",	(String)appInfo.get("conditionUrl"));
		result.put("privateInfoUrl",(String)appInfo.get("privateInfoUrl"));
		
		result.put("resultMessage", param);
		return result;
	}	
	
	@RequestMapping(value="/noticelist")
	@ResponseBody
	public Object noticelist(@RequestParam(value="authKey", 		required=true) 				String authKey
							,@RequestParam(value="mediaCd", 	defaultValue="mcdoheapp")		String mediaCd
							,@RequestParam(value="userId", 		required=true) 					String userId
							,@RequestParam(value="gid", 		defaultValue="XXXXXXXXXX") 		String gid
							,@RequestParam(value="reqPage", 	defaultValue="1") 				int reqPage
							,@RequestParam(value="listPerPage", defaultValue="30") 				int listPerPage
							,HttpServletRequest req )
	{
		int start = (reqPage * listPerPage - listPerPage);
		HashMap<String, Object> param	=	new	HashMap<String, Object>();
		
		param.put("authKey",	authKey);
		param.put("mediaCd",	mediaCd);
		param.put("userId", 	userId);
		param.put("gid", 		gid);
		param.put("reqPage",	reqPage);
		param.put("listPerPage",listPerPage);
		param.put("start", start);
		
		
		int		listCnt		=	0;
		String 	lastPage	=	"Y";
		
		listCnt	=	oh2gameMypageDao.getNoticeListCnt(param);
		
		if(listCnt > (reqPage*listPerPage)){
			lastPage	=	"N";
		}
		
		List<NoticeInfoVo> noticeList	=	oh2gameMypageDao.getNoticeList(param);
		

		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType",	"noticelist");
		result.put("result",	"1000");
		result.put("listCnt",	noticeList.size());
		result.put("pageNo",	reqPage);
		result.put("lastPage",	lastPage);
		result.put("noticeInfo",noticeList);
		result.put("resultMessage", param);
		return result;	
	}
	
	@RequestMapping(value="/getpushsetting")
	@ResponseBody
	public Object getPushSetting(@RequestParam(value="authKey", 		required=true) 				String authKey
								,@RequestParam(value="mediaCd", 	defaultValue="mcdoheapp")	String mediaCd
								,@RequestParam(value="userId", 		required=true) 				String userId
								,@RequestParam(value="gid", 		defaultValue="XXXXXXXXXX") 	String gid
								,HttpServletRequest req ){
		HashMap<String, Object> param	=	new	HashMap<String, Object>();
		
		param.put("authKey", 	authKey);
		param.put("mediaCd", 	mediaCd);
		param.put("userId", 	userId);
		param.put("gid", 		gid);
		
		
		HashMap<String, Object> hSetting	=	oh2gameMypageDao.getPushSetting(param);
		
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType","getpushsetting");
		result.put("result","1000");
		
		if(hSetting	!=	null){
			result.put("pushMethod", 	(String)hSetting.get("pushMethod"));
			result.put("service", 		(String)hSetting.get("service"));
			result.put("comm", 			(String)hSetting.get("comm"));
		}else{
			result.put("pushMethod", 	"");
			result.put("service", 		"");
			result.put("comm", 			"");
		}
		result.put("resultMessage", param);
		return result;
		
		
	}
	
	@RequestMapping(value="/pushsetting")
	@ResponseBody
	public Object pushsetting(@RequestParam(value="authKey", 		required=true) 				String authKey
								,@RequestParam(value="mediaCd", 	defaultValue="mcdoheapp")	String mediaCd
								,@RequestParam(value="userId", 		required=true) 				String userId
								,@RequestParam(value="gid", 		defaultValue="XXXXXXXXXX") 	String gid
								,@RequestParam(value="pushMethod", 	required=true) 				String pushMethod
								,@RequestParam(value="service", 	required=true) 				String service
								,@RequestParam(value="comm", 		required=true) 				String comm
								//,@RequestParam(value="pushKey", 		required=true) 			String pushKey
								,HttpServletRequest req )
	{
		HashMap<String, Object> param	=	new	HashMap<String, Object>();
		
		param.put("authKey", 	authKey);
		param.put("mediaCd", 	mediaCd);
		param.put("userId", 	userId);
		param.put("gid", 		gid);
		param.put("pushMethod", pushMethod);
		param.put("service", 	service);
		param.put("comm", 		comm);
		
		HashMap<String, Object> pushInfo	=	oh2gameMypageDao.getPushSetting(param);
		if(pushInfo	!=	null){
			oh2gameMypageDao.updatePushSetting(param);
		}else{
			oh2gameMypageDao.insertPushSetting(param);
		}
		
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType","pushsetting");
		result.put("result","1000");
		result.put("pushMethod", pushMethod);
		result.put("service", 	service);
		result.put("comm", 		comm);
		
		
		
		result.put("resultMessage", param);
		return result;
	}
	
	@RequestMapping(value="/logout")
	@ResponseBody
	public Object logout(@RequestParam(value="authKey", 	required=true) 				String authKey
							,@RequestParam(value="mediaCd", defaultValue="mcdoheapp")	String mediaCd
							,@RequestParam(value="userId", 	required=true) 				String userId
							,@RequestParam(value="gid", 	defaultValue="XXXXXXXXXX") 	String gid
							,HttpServletRequest req )
	{
		HashMap<String, Object> param	=	new	HashMap<String, Object>();
		
		param.put("authKey", 	authKey);
		param.put("mediaCd", 	mediaCd);
		param.put("userId", 	userId);
		param.put("gid", 		gid);
		
		this.oh2gameMypageDao.logout(param);
		
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType","logout");
		result.put("result","1000");
		
		result.put("resultMessage", param);
		return result;
	}
	
	@RequestMapping(value="/snsreg")
	@ResponseBody
	public Object snsreg(@RequestParam(value="authKey", 	required=true) 				String authKey
							,@RequestParam(value="mediaCd", defaultValue="mcdoheapp")	String mediaCd
							,@RequestParam(value="userId", 	required=true) 				String userId
							,@RequestParam(value="gid", 	defaultValue="XXXXXXXXXX") 	String gid
							,@RequestParam(value="snsType",	required=true) 				String snsType
							,@RequestParam(value="snsId", 	required=true) 				String snsId
							,HttpServletRequest req )
	{
		HashMap<String, Object> param	=	new	HashMap<String, Object>();
		
		param.put("authKey", 	authKey);
		param.put("mediaCd", 	mediaCd);
		param.put("userId", 	userId);
		param.put("gid", 		gid);
		param.put("snsType", 	snsType);
		param.put("snsId", 		snsId);
		
		this.oh2gameMypageDao.regSnsInfo(param);
		
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("resType","snsreg");
		result.put("result","1000");
		
		result.put("resultMessage", param);
		return result;
	}
	
	@RequestMapping(value="/getsnsinfo")
	@ResponseBody
	public Object getSnsInfo(@RequestParam(value="authKey", required=true) 				String authKey
							,@RequestParam(value="mediaCd", defaultValue="mcdoheapp")	String mediaCd
							,@RequestParam(value="userId", 	required=true) 				String userId
							,@RequestParam(value="gid", 	defaultValue="XXXXXXXXXX") 	String gid
							,HttpServletRequest req )
	{
		HashMap<String, Object> param	=	new	HashMap<String, Object>();
		
		param.put("authKey", 	authKey);
		param.put("mediaCd", 	mediaCd);
		param.put("userId", 	userId);
		param.put("gid", 		gid);
		
		List<UserSnsInfoVo>	snsInfo	=	this.oh2gameMypageDao.getUserSnsInfo(param);
		
		Hashtable<String, Object> result	=	new	Hashtable<String, Object>();
		result.put("snsInfo", snsInfo);
		result.put("resType","getsnsinfo");
		result.put("result","1000");
		
		result.put("resultMessage", param);
		return result;
	}
	
	@RequestMapping(value="/pushtest")
	@ResponseBody
	public Object pushtest(	@RequestParam(value="type", required=true) 				int type
							,@RequestParam(value="regId", required=true)			String regId
							,@RequestParam(value="msg", defaultValue="")			String mesg){
		
		String EVENT = "{\"eventType\":\"EVENT\",\"title\" : \"new event\", \"eventId\": 1}";
		String PUBLISH = "{\"eventType\":\"PUBLISH\",\"title\" : \"publish\", \"eventId\": 1}";
		String NOTICE = "{\"eventType\":\"NOTICE\",\"title\" : \"notice\", \"noticeId\": 1}";
		String BOARD_REPLY = "{\"eventType\":\"BOARD_REPLY\",\"title\":\"boardReply\",\"text\" : \"new reply for you posted(boardReply)\", \"boardId\": 1}";
		String EVENT_REPLY = "{\"eventType\":\"EVENT_REPLY\",\"title\":\"eventReply\",\"text\" : \"new reply for you posted(eventReply)\", \"boardId\": 1, \"eventId\":1}";
		String BOARD_REPORT = "{\"eventType\":\"BOARD_REPORT\",\"title\":\"boardReportAlert\",\"text\" : \"report for you posted(boardReport)\",\"reason\":\"$reason\", \"boardId\": 1}";
		String BOARD_REPLY_REPORT = "{\"eventType\":\"BOARD_REPLY_REPORT\",\"title\":\"boardReplyReportAlert\",\"text\" : \"report for you posted(boardReplyReport)\",\"reason\":\"reason\", \"boardId\": 1}";
		String EVENT_REPLY_REPORT = "{\"eventType\":\"EVENT_REPLY_REPORT\",\"title\":\"eventReplyReportAlert\",\"text\" : \"report for you posted(eventReplyReport)\",\"reason\":\"reason\", \"boardId\": 1, \"eventId\":1}";
		
		String msg	=	"";
		if(mesg.equals("")){
			switch(type){
				case 1: msg	=	EVENT;				break;
				case 2: msg	=	PUBLISH;			break;
				case 3: msg	=	NOTICE;				break;
				case 4: msg	=	BOARD_REPLY;		break;
				case 5: msg	=	EVENT_REPLY;		break;
				case 6: msg	=	BOARD_REPORT;		break;
				case 7: msg	=	BOARD_REPLY_REPORT;	break;
				case 8: msg	=	EVENT_REPLY_REPORT;	break;
				
			}
		}else{
			msg	=	mesg;
		}
		
		Sender sender	=	new	Sender("AIzaSyATeHJeoQGBd3n7hDuTpIVEr-vAIyk8ZiA");
		
		Message message	=	new	Message.Builder().addData("msg", msg).build();
		
		String cliendPushKey	=	"APA91bE2GfHH7rML1-Q5AKOnlUhgDohs4RmfGg8p-E-zq3yq5-Zz3yG8jb9yQpZlIPBMcDQQ4XWSkx1NDtRGb2FqAC5LAFYmR9985BphWK_zLC1g2MpLWQkzo5rnuE4_rjllKMH507l4LiB9HMpBriG0iy2cTSpfyA";
		cliendPushKey	=	regId;
		Result	result	=	null;
		try{		
			result	=	sender.send(message, cliendPushKey, 5);
		}catch(IOException e){
			e.printStackTrace();
		}
		System.out.println("messageId : "+result.getMessageId());
		System.out.println("errorCode  : "+result.getErrorCodeName());
		
		return msg;
		
	}
	
}

